//
// Created by tongj on 2024/1/13.
//

#ifndef TBS_CPP_WRAPPER_CUH
#define TBS_CPP_WRAPPER_CUH

template<typename T> void Wrapper<T>::releaseWrap(Wrapper<T> &item) {
  ASSERT(item._hasRelease, "this Wrapper had been released");
  item.m_release();
  item._hasRelease = true;
}

template<typename T> Wrapper<T>::~Wrapper() {
  if (!_hasRelease) {
	releaseWrap(*this);
  }
}

template<typename T> T &Wrapper<T>::operator*() {
  return value();
}

template<typename V> void WrappedDestruction(Wrapper<V> *v) {
  if (v != nullptr) {
	Wrapper<V>::releaseWrap(*v);
  }

}

#endif //TBS_CPP_WRAPPER_CUH
